inspector: Disable non-functional controls
authorMatthias Clasen <mclasen@redhat.com>
Thu, 10 Jul 2014 14:33:27 +0000 (10:33 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Thu, 10 Jul 2014 14:33:27 +0000 (10:33 -0400)
Some of the features we expose can be hardcoded via environment
variables. In that case, don't confuse the user by letting them
change settings that have no effect.

gtk/inspector/general.c
gtk/inspector/visual.c

index ae8b2d75eff9240cb7073ceea259de44c6d8500d..cd00e382e63fd5f6b0fa7b29bc09851dd811a35a 100644 (file)
@@ -15,6 +15,9 @@
  * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include "config.h"
+#include <glib/gi18n-lib.h>
+
 #include "general.h"
 
 #include "gtkprivate.h"
@@ -157,6 +160,14 @@ init_touch (GtkInspectorGeneral *gen)
   gtk_switch_set_active (GTK_SWITCH (gen->priv->touchscreen_switch), (gtk_get_debug_flags () & GTK_DEBUG_TOUCHSCREEN) != 0);
   g_signal_connect (gen->priv->touchscreen_switch, "notify::active",
                     G_CALLBACK (update_touchscreen), gen);
+
+  if (g_getenv ("GTK_TEST_TOUCHSCREEN") != 0)
+    {
+      /* hardcoded, nothing we can do */
+      gtk_switch_set_active (GTK_SWITCH (gen->priv->touchscreen_switch), TRUE);
+      gtk_widget_set_sensitive (gen->priv->touchscreen_switch, FALSE);
+      gtk_widget_set_tooltip_text (gen->priv->touchscreen_switch, _("Setting is hardcoded by GTK_TEST_TOUCHSCREEN"));
+    }
 }
 
 static void
index 435198aeac602e48d710a11753628a3ec9f6786d..4970119e2e6385c8771ac0871a84591fea1341ae 100644 (file)
@@ -15,6 +15,8 @@
  * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include "config.h"
+#include <glib/gi18n-lib.h>
 #include "visual.h"
 
 #include "gtkprivate.h"
@@ -211,6 +213,13 @@ init_theme (GtkInspectorVisual *vis)
   g_hash_table_destroy (t);
 
   gtk_combo_box_set_active (GTK_COMBO_BOX (vis->priv->theme_combo), pos);
+
+  if (g_getenv ("GTK_THEME") != NULL)
+    {
+      /* theme is hardcoded, nothing we can do */
+      gtk_widget_set_sensitive (vis->priv->theme_combo, FALSE);
+      gtk_widget_set_tooltip_text (vis->priv->theme_combo , _("Theme is hardcoded by GTK_THEME"));
+    }
 }
 
 static void
@@ -230,6 +239,13 @@ init_dark (GtkInspectorVisual *vis)
   g_object_bind_property (vis->priv->dark_switch, "active",
                           gtk_settings_get_default (), "gtk-application-prefer-dark-theme",
                           G_BINDING_BIDIRECTIONAL);
+
+  if (g_getenv ("GTK_THEME") != NULL)
+    {
+      /* theme is hardcoded, nothing we can do */
+      gtk_widget_set_sensitive (vis->priv->dark_switch, FALSE);
+      gtk_widget_set_tooltip_text (vis->priv->dark_switch, _("Theme is hardcoded by GTK_THEME"));
+    }
 }
 
 static void